package com.info.zhiduoduo.core.dto.dayspay;

import com.info.zhiduoduo.common.validator.IntIn;
import com.info.zhiduoduo.repository.entity.crowdsource.CrowdsourceTradeRecordItem;
import com.info.zhiduoduo.repository.entity.order.TradeRecord;
import com.info.zhiduoduo.repository.entity.partner.PartnerWithdraw;

import java.math.BigDecimal;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

@Data
@AllArgsConstructor
@NoArgsConstructor
@Accessors(chain = true)
public class DaysAgentPayFormBean {

	/**  平台交易编号 */
	private String tradeNo;
	/** 交易金额(单位元) */
	private BigDecimal tradeamount;
	/** 交易说明 */
	private String purpose;
	/** 银行卡号 */
	private String acctNo;
	/** 账户姓名 */
	private String acctName;
	/** 银行名(对公账户需要) */
	private String bankName;
	/** 国内对公填写支行名 */
	private String branchNo;
	/** 开户省份	国内对公填 */
	private String province;
	/** 开户城市	国内对公填 */
	private String city;
	/** 1:代表个人账户  2:代表企业账户 */
	private int acctType;
	/** 得仕商户号 1:九歌 2:武圣 3:智圣 */
	@IntIn(value = {1, 2, 3}, message = "商户号不正确")
	private int paymentMerchant;

	public static DaysAgentPayFormBean of(TradeRecord tradeRecord) {
		return new DaysAgentPayFormBean().setTradeNo(tradeRecord.getTradeno())
				.setAcctName(tradeRecord.getAcctname())
				.setAcctNo(tradeRecord.getAcctno())
				.setAcctType(tradeRecord.getAccttype())
				.setPurpose(tradeRecord.getPurpose())
				.setTradeamount(tradeRecord.getTradeamount())
				.setBankName(tradeRecord.getBankname())
				.setBranchNo(tradeRecord.getBranchName())
				.setProvince(tradeRecord.getBankProvince())
				.setCity(tradeRecord.getBankCity())
				.setPaymentMerchant(tradeRecord.getMerchantid());
	}

	public static DaysAgentPayFormBean of(CrowdsourceTradeRecordItem recordItem, int merchantId) {
		return new DaysAgentPayFormBean().setTradeNo(recordItem.getTradeNo())
				.setAcctName(recordItem.getAcctname())
				.setAcctNo(recordItem.getAcctno())
				.setAcctType(recordItem.getAccttype())
				.setPurpose(recordItem.getPurpose())
				.setTradeamount(recordItem.getTradeamount())
				.setBankName(recordItem.getBankname())
				.setPaymentMerchant(merchantId);
	}

	public static DaysAgentPayFormBean of(PartnerWithdraw withdraw, int merchantId) {
		return new DaysAgentPayFormBean().setTradeNo(withdraw.getWdno())
				.setAcctName(withdraw.getAcctname())
				.setAcctNo(withdraw.getAcctno())
				.setAcctType(1)
				.setPurpose(withdraw.getPurpose())
				.setTradeamount(withdraw.getAmount())
				.setBankName(withdraw.getBankname())
				.setPaymentMerchant(merchantId);
	}
}
